package com.genius.reservation.platform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.genius.reservation.mapper.PlatformInformationMapper;
import com.genius.reservation.platform.entity.PlatformInformation;
import com.genius.reservation.platform.service.IPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class PlatformServiceImpl extends ServiceImpl<PlatformInformationMapper, PlatformInformation> implements IPlatformService {
    @Autowired
    PlatformInformationMapper platformInformationMapper;
    @Override
    public List<PlatformInformation> findFreePlatform() {
        LambdaQueryWrapper<PlatformInformation> last = platformInformationMapper.getQueryWrapper().eq(PlatformInformation::getPlatformIsUse, 0).last("LIMIT 1");
        return platformInformationMapper.selectList(last);
    }

    @Override
    public PlatformInformation findPlatformById(String platformNumber) {
        LambdaQueryWrapper<PlatformInformation> last = platformInformationMapper.getQueryWrapper().eq(PlatformInformation::getPlatformNumber, platformNumber).last("LIMIT 1");
        return platformInformationMapper.selectOne(last);
    }
}
